package com.tk.demo.fwk.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tk.demo.fwk.rdb.Rdb;

public class RoutingServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		routing(req,resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		routing(req,resp);
	}
	protected void routing(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
		String UUID = req.getParameter("UUID");
		String view = getView(UUID);
		req.getRequestDispatcher(view).forward(req,resp);
	}
	
	public String getView(String UUID){
		String sql = "select VIEW_PATH from TK_VIEW where UUID = '" + UUID + "' and OPEN = 'T'";
		return (Rdb.getResultString(sql));
	}
	
}
